<template>
	<!--财务信息 -->
	<div>
		<FormPanel
			ref="FormPanel"
			:list="initForm"
			:cols="2"
			:formType="formType"
			:labelWidth="150"
			:isSubmitBtn="false"
			@formChange="formChangeHandle"
			class="mtop"
		/>
	</div>
</template>

<script>
	import { dictionary } from '@/utils/dictMixin';
	import * as types from '@/api/cms-api/origin/originInfo/types';

	import vm from './bridge';

	export default {
		mixins: [dictionary],
		model:{
			prop:'pdata',
			event:'click'
		},
		props: {
			pdata: {
				type: Object,
				default: () => ({})
			},
			formType:{
				type: String,
				required:true
			}
		},
		data() {
			return {
				initForm: this.initFormFun(),
			};
		},
		mounted(){
			//注册经销商类型变化时触发的事件
			vm.$on('changeDealerType',this.changeDealerType);
		},
		methods: {
			//初始化数据
			init() {
				this.initForm.forEach(x => {
					x.initialValue = this.pdata[x.fieldName];
				});
			},
			formChangeHandle(val) {
				this.pdata = Object.assign(this.pdata,val);
				//传递数据到父组件里
				this.$emit('click', this.pdata);
				//触发外部的事件，以标志着本表单已经准备完毕
				this.$emit('formchange', this.pdata);
			},
			saveDialog(){
				this.$refs.FormPanel.SUBMIT_FORM();
			},
			//经销商类型变更时
			changeDealerType(value){
				if(types.DEALER_INFO_DEALER_TYPE_BIG_CUSTOMER === value){
					//this.financeEnabled();
				}else{
					this.financeDisabled();
				}
				// this.refreshFormRules();
			},
			//禁用财务信息部分
			financeDisabled(){
				vm.financeDisabled(this.initForm,false);
				vm.clearValidate(this.$refs.FormPanel);
			},
			//启用财务信息部分
			financeEnabled(){
				vm.financeEnabled(this.initForm,false);
				vm.clearValidate(this.$refs.FormPanel);
			},
			//刷新验证内容
			// refreshFormRules(){
			// 	vm.refreshFormRules(this,this.$refs.FormPanel,this.initForm);
			// },
			//搜索数据
			initFormFun() {
				return [
					{type:'INPUT',label:'开户银行名称',fieldName:'bank',initialValue:'',maxlength:300,placeholder:'',},
					{type:'INPUT',label:'开户行行号',fieldName:'bankNum',initialValue:'',maxlength:60,placeholder:'',},
					{type:'INPUT',label:'银行账号',fieldName:'bankAccount',initialValue:'',maxlength:60,placeholder:'',},
					{type:'INPUT',label:'分账账号',fieldName:'subAccount',initialValue:'',maxlength:60,placeholder:'',},
					{type:'INPUT',label:'邮编',fieldName:'zipCode',initialValue:'',maxlength:6,placeholder:'',rules:[{ required: true, message: '必填', trigger: ['change', 'blur'] }]},
					{type:'INPUT',label:'开票电话',fieldName:'invoicePhone',initialValue:'',maxlength:30,placeholder:'',},
					{type:'INPUT',label:'财务负责人电话',fieldName:'financePhone',initialValue:'',maxlength:30,placeholder:'',},
					{type:'TEXT_AREA',label:'发票邮寄地址',rows:1,fieldName:'billSendAddress',initialValue:'',maxlength:300,placeholder:'',},
					{type:'INPUT',label:'发票邮寄收件人',fieldName:'billAddressee',initialValue:'',maxlength:100,placeholder:'',},
					{type:'INPUT',label:'发票邮寄收件电话',fieldName:'billReceiveLinkman',initialValue:'',maxlength:20,placeholder:'',},
					{type:'INPUT',label:'紧急联系人',fieldName:'emergencyContract',initialValue:'',maxlength:100,placeholder:'',},
					{type:'INPUT',label:'紧急联系电话',fieldName:'emergencyContractPhone',initialValue:'',maxlength:20,placeholder:'',},
					{type: 'UPLOAD_FILE',label: '开户证明附件',selfCols:2, fieldName: 'openAccountProveEnclosureList',initialValue: [],
						disabled:false,
						upload: {
							actionUrl: '/api/file/oss/upload', //上传的地址
							limit: 99, //上传数量
							fileTypes:[
								'jpg','jpeg','png','gif',
								'doc','docx','xls','xlsx','ppt','pptx','txt','pdf',
								'rar','zip',
							],
						},
					},
				];
			},
		}
	};
</script>
